package com.haier.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haier.dto.HpAreaAuditorDto;
import com.haier.entity.HpAreaAuditor;
import com.haier.mapper.HpAreaAuditorMapper;
import com.haier.service.IHpAreaAuditorService;
import com.haier.utils.BeanUtil;
import com.haier.utils.EmptyUtils;
import com.haier.vo.ResponseVo;

/**
 * <p>
 * 区域审核人 服务实现类
 * </p>
 *
 * @author luanxuecheng
 * @since 2020-07-01
 */
@Service
@Transactional(rollbackFor = Throwable.class)
public class HpAreaAuditorServiceImpl extends ServiceImpl<HpAreaAuditorMapper, HpAreaAuditor>
		implements IHpAreaAuditorService {

	@Override
	public ResponseVo edit(HpAreaAuditorDto dto) {
		HpAreaAuditor bean = new HpAreaAuditor();
		BeanUtil.copyNotNullBean(dto, bean);
		if (EmptyUtils.isEmpty(dto.getId())) {
			baseMapper.insert(bean);
		} else {
			baseMapper.updateById(bean);
		}
		JSONObject result = new JSONObject();
		result.put("id", bean.getId());
		return ResponseVo.success(result);
	}

	@Override
	public ResponseVo remove(HpAreaAuditorDto dto) {
		baseMapper.deleteById(dto.getId());
		return ResponseVo.success();
	}

}
